#ifndef WINC_H_
#define WINC_H_

/* winc.h - interface to "Windows C Library".
 *
 * The Windows C library is code that offers services similar
 * to the standard C runtime library without requiring you to
 * actually load the C runtime library.
 */

#ifndef _WINDOWS_
#   pragma warning(disable: 4115)
#   include <windows.h>
#   pragma warning(default: 4115)
#endif
#ifdef  _MSC_VER
#   pragma warning(disable: 4201)
#endif
#include <shlwapi.h>
#ifdef _MSC_VER
#   pragma warning(default: 4201)
#endif
#ifndef INVALID_FILE_ATTRIBUTES
#   define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
#endif


extern HANDLE   WcStderr;
extern HANDLE   WcStdout;
extern HANDLE   WcStdin;

void    WcInit(void);

void*   WcMalloc(size_t Size);
void*   WcRealloc(void* Ptr, size_t Size);
void    WcFree(void* Ptr);
void*   WcCalloc(size_t Count, size_t Size);

void*   WcMemCpy(void* To, const void* From, size_t NBytes);
void*   WcMemSet(void* Target, int Char, size_t NBytes);
#define WCMEMZERO(Object) WcMemSet(Object, 0, sizeof(*Object))

void    WcExit(int Code);

#define WCNEW(TypeName) (TypeName*)WcCalloc(1, sizeof(TypeName))

char*   WcStrDupA(const char* Str);
wchar_t*WcStrDupW(const wchar_t* Str);
wchar_t*WcStrnDupW(const wchar_t* Str, size_t Count);

void    WcErrorW(const wchar_t* Format, ...);
void    WcPrintfW(const wchar_t* Format, ...);
void    WcFPrintfW(HANDLE Handle, const wchar_t* Format, ...);

__int64 WcGetFileModTimeW(const wchar_t* FileName);
__int64 WcGetCurrentTime(void);


void    WcAssert(long Line, const char* Filename, const char* Expr);

//#define WCASSERT(e) if(!(e)) WcAssert(__LINE__, __FILE__, #e);
#define WCASSERT(e) (!(e) ? WcAssert(__LINE__, __FILE__, #e) : (void)0)
#define WCASSERTDESIGN(e) if(!(e)) WcAssert(__LINE__, __FILE__, #e);

#define WCASSERTFAILED()    WcAssert(__LINE__, __FILE__, "can't happen")

#define WCUNUSED(arg) if(arg != 0) ;

#define WCVERIFY(e) if(!(e)) WcAssert(__LINE__, __FILE__, #e);

#endif
